/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package net.jcdev.coolrss.model.entity;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author carlos
 */
@Entity
@Table(name = "FEED")
@NamedQueries({
    @NamedQuery(name = "Feed.findAll", query = "SELECT f FROM Feed f"),
    @NamedQuery(name = "Feed.findByFeedTitle", query = "SELECT f FROM Feed f WHERE f.feedTitle = :feedTitle"),
    @NamedQuery(name = "Feed.findByFeedLink", query = "SELECT f FROM Feed f WHERE f.feedLink = :feedLink"),
    @NamedQuery(name = "Feed.findByFeedPublishedDate", query = "SELECT f FROM Feed f WHERE f.feedPublishedDate = :feedPublishedDate")})
public class Feed implements Serializable {
    private static final long serialVersionUID = 1L;
    @Column(name = "FEED_TITLE")
    private String feedTitle;
    @Lob
    @Column(name = "FEED_DESCRIPTION")
    private String feedDescription;
    @Id
    @Basic(optional = false)
    @Column(name = "FEED_LINK")
    private String feedLink;
    @Column(name = "FEED_PUBLISHED_DATE")
    @Temporal(TemporalType.TIMESTAMP)
    private Date feedPublishedDate;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "feedLink")
    private List<Entry> entryList;
    @JoinColumn(name = "TAG_NAME", referencedColumnName = "TAG_NAME")
    @ManyToOne(optional = false)
    private Tag tagName;

    public Feed() {
    }

    public Feed(String feedLink) {
        this.feedLink = feedLink;
    }

    public String getFeedTitle() {
        return feedTitle;
    }

    public void setFeedTitle(String feedTitle) {
        this.feedTitle = feedTitle;
    }

    public String getFeedDescription() {
        return feedDescription;
    }

    public void setFeedDescription(String feedDescription) {
        this.feedDescription = feedDescription;
    }

    public String getFeedLink() {
        return feedLink;
    }

    public void setFeedLink(String feedLink) {
        this.feedLink = feedLink;
    }

    public Date getFeedPublishedDate() {
        return feedPublishedDate;
    }

    public void setFeedPublishedDate(Date feedPublishedDate) {
        this.feedPublishedDate = feedPublishedDate;
    }

    public List<Entry> getEntryList() {
        return entryList;
    }

    public void setEntryList(List<Entry> entryList) {
        this.entryList = entryList;
    }

    public Tag getTagName() {
        return tagName;
    }

    public void setTagName(Tag tagName) {
        this.tagName = tagName;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (feedLink != null ? feedLink.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Feed)) {
            return false;
        }
        Feed other = (Feed) object;
        if ((this.feedLink == null && other.feedLink != null) || (this.feedLink != null && !this.feedLink.equals(other.feedLink))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "net.jcdev.coolrss.model.entity.Feed[feedLink=" + feedLink + "]";
    }

}
